﻿Imports Microsoft.Build.Tasks
Imports System
Imports System.IO
Imports System.Xml

Namespace System.Workflow.ComponentModel.Compiler
    Friend Class TasksHelper
        ' Methods
        Friend Shared Function GetXomlManifestName(ByVal fileName As String, ByVal linkFileName As String, ByVal rootNamespace As String, ByVal binaryStream As Stream) As String
            Dim str As String = String.Empty
            Dim name As String = linkFileName
            If ((name Is Nothing) OrElse (name.Length = 0)) Then
                name = fileName
            End If
            Dim itemCultureInfo As ItemCultureInfo = Culture.GetItemCultureInfo(name)
            If (Not binaryStream Is Nothing) Then
                Dim str3 As String = Nothing
                Try 
                    Dim reader As New XmlTextReader(binaryStream)
                    If ((reader.MoveToContent = XmlNodeType.Element) AndAlso reader.MoveToAttribute("Class", "http://schemas.microsoft.com/winfx/2006/xaml")) Then
                        str3 = reader.Value
                    End If
                Catch obj1 As Object
                End Try
                If ((Not str3 Is Nothing) AndAlso (str3.Length > 0)) Then
                    str = str3
                    If ((Not itemCultureInfo.culture Is Nothing) AndAlso (itemCultureInfo.culture.Length > 0)) Then
                        str = (str & "." & itemCultureInfo.culture)
                    End If
                End If
            End If
            If (str.Length = 0) Then
                If Not String.IsNullOrEmpty(rootNamespace) Then
                    str = (rootNamespace & ".")
                End If
                Dim str4 As String = CreateManifestResourceName.MakeValidEverettIdentifier(Path.GetDirectoryName(itemCultureInfo.cultureNeutralFilename))
                If (String.Compare(Path.GetExtension(itemCultureInfo.cultureNeutralFilename), ".resx", StringComparison.OrdinalIgnoreCase) = 0) Then
                    str = (str & Path.Combine(str4, Path.GetFileNameWithoutExtension(itemCultureInfo.cultureNeutralFilename))).Replace(Path.DirectorySeparatorChar, "."c).Replace(Path.AltDirectorySeparatorChar, "."c)
                    If ((Not itemCultureInfo.culture Is Nothing) AndAlso (itemCultureInfo.culture.Length > 0)) Then
                        str = (str & "." & itemCultureInfo.culture)
                    End If
                    Return str
                End If
                str = (str & Path.Combine(str4, Path.GetFileName(itemCultureInfo.cultureNeutralFilename))).Replace(Path.DirectorySeparatorChar, "."c).Replace(Path.AltDirectorySeparatorChar, "."c)
                If ((Not itemCultureInfo.culture Is Nothing) AndAlso (itemCultureInfo.culture.Length > 0)) Then
                    str = (itemCultureInfo.culture & Path.DirectorySeparatorChar & str)
                End If
            End If
            Return str
        End Function

    End Class
End Namespace

